<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 400px;
            margin: 0 auto;
        }

        .box .huawei {
            display: flex;
            border-bottom: 1px dashed;
        }

        .box .huawei p {
            margin-right: 40px;
        }

        .box .srco {
            margin-top: 11px;
        }

        .box .srco input {
            width: 35px;
            height: 25px;
        }
    </style>
</head>

<body>
    <!-- 实现购物车案例 -->

    <div class="box">
        <div class="huawei">
            <p>华为手机</p>
            <p>￥3000</p>
            <div class="srco">
                <input type="text" placeholder="0" class="huaweiinp">台
                <button id="huawei">+</button>
                <button id="huaweij">-</button>
            </div>
        </div>
        <div class="huawei">
            <p>oppo手机</p>
            <p>￥2000</p>
            <div class="srco">
                <input type="text" placeholder="0" class="oppoinp">台
                <button id="oppo">+</button>
                <button id="oppoj">-</button>
            </div>
        </div>
        <div class="huawei">
            <p>苹果手机</p>
            <p>￥5000</p>
            <div class="srco">
                <input type="text" placeholder="0" class="pingguoinp">台
                <button id="pingguo">+</button>
                <button id="pingguoj">-</button>
            </div>
        </div>
        <div class="total">
            共选择
            <span class="tow">0</span>台
            总计
            <span class="mac">0</span>元
        </div>

    </div>
    <script>
        /* 点击+ input里面的数字+ tow里面的数字+ 
        点击- input里面的数字- tow里面的数字- mac里面的数字根据点击次数*单价返回给mac*/

        let huawei = document.querySelector("#huawei")
        let huaweij = document.querySelector("#huaweij")
        // let oppo = document.querySelector("#oppo")
        // let oppoj = document.querySelector("#oppoj")
        // let pingguo = document.querySelector("#pingguo")
        // let pingguoj = document.querySelector("#pingguoj")
        let inph = document.querySelector(".huaweiinp")
        // let inpo=document.querySelector(".oppoinp")
        // let inpp=document.querySelector(".pingguoinp")
        console.log(huawei, huaweij, inph);
        let huaweinum = 0
        // let opponum=0


        huawei.addEventListener("click", function () {
            let huaweiq = huaweinum++
            inph.placeholder = huaweiq

            huaweij.addEventListener("click", function () {
                let huaweijian = huaweiq--
                inph.placeholder = huaweijian
            })

        })




        // oppo.addEventListener("click", function () {
        //     let oppoq=opponum++
        //     inpo.placeholder=oppoq
        // })
        // oppoj.addEventListener("click", function () {
        //     let oppoq=num--
        //     inp.placeholder=huaweiq
        // })
        // pingguo.addEventListener("click", function () {
        //     let huaweiq=huaweinum++
        //     inp.placeholder=huaweiq
        // })
        // pingguo.addEventListener("click", function () {
        //     let huaweiq=huaweinum++

        //     inp.placeholder=huaweiq
        // })

    </script>
</body>

</html>